package com.smart.web.controller.user.watches;

import com.smart.common.core.domain.R;
import com.smart.common.enums.DeviceActionEnum;
import com.smart.common.utils.modbus.ModbusUtil;
import com.smart.system.domain.dto.DeviceSettingsDto;
import com.smart.system.service.IWatchesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestSendController {
    @Autowired
    private IWatchesService watchersService;

    @GetMapping("/send")
    public R send(){
//        watchersService.sendInstruct("358800015276059", null, DeviceActionEnum.REMOTE_LOCATION.getCode());
        return R.ok();
    }

    @GetMapping("/send1")
    public R send1(){
        DeviceSettingsDto dto = new DeviceSettingsDto();
        dto.setDeviceid("358800015276059");
        dto.setLocationtimeinterval("1");
        dto.setHeartratetimeinterval("5");
        dto.setBpi("5");
        dto.setTpi("5");
        dto.setOxi("5");
        watchersService.updateDevice(dto);
        return R.ok();
    }

    @GetMapping("/sendDtu")
    public R sendDtu(String data){
        ModbusUtil.Modbus analysis = ModbusUtil.analysis(data);
        System.err.println(analysis);
        return R.ok();
    }
}
